package com.project.model.core;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.project.model.common.OrderEntity;

import java.util.List;

/**
 * 区域管理
 *
 * @version 1.0 2016-05-09
 */
public class Area extends OrderEntity {

    private static final long serialVersionUID = 9532273447665664L;

    /**
     * 区域路径分隔符
     */
    public static final String TREE_PATH_SEPARATOR = ",";
    /**
     * 区域全名分割符
     */
    public static final String FULL_NAME_SEPARATOR = " ";

    /**
     * 名称
     */
    private String name;

    /**
     * 父节点
     */
    private Long parentId;

    /**
     * 全名
     */
    private String fullName;

    /**
     * 路径
     */
    private String treePath;

    /**
     * 等级
     */
    private Integer grade;

    private Integer region;

    private String areaCode;

    private String carPrefix;

    /**
     * 地区首字母
     */
    private String areaFirstLetter;

    /*************************扩展属性***********************************/
    /**
     * 子节点数量
     */
    private int childCount = 0;

    /**
     * 父级节点名称
     */
    private String parentName;

    /**
     * 受否为父级节点
     */
    private Boolean isParent;

    /**
     * 子区域
     */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<Area> areas;

    /**
     * 获取名称
     */
    @JsonProperty
    public String getName() {
        return name;
    }

    /**
     * 设置名称
     */
    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    /**
     * 获取父节点
     */
    @JsonProperty
    public Long getParentId() {
        return parentId;
    }

    /**
     * 设置父节点
     */
    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    /**
     * 获取全名
     */
    @JsonProperty
    public String getFullName() {
        return fullName;
    }

    /**
     * 设置全名
     */
    public void setFullName(String fullName) {
        this.fullName = fullName == null ? null : fullName;
    }

    /**
     * 获取路径
     */
    @JsonProperty
    public String getTreePath() {
        return treePath;
    }

    /**
     * 设置路径
     */
    public void setTreePath(String treePath) {
        this.treePath = treePath == null ? null : treePath.trim();
    }

    /**
     * 获取等级
     */
    @JsonProperty
    public Integer getGrade() {
        return grade;
    }

    /**
     * 设置等级
     */
    public void setGrade(Integer grade) {
        this.grade = grade;
    }

    @JsonProperty
    public Integer getRegion() {
        return region;
    }

    public void setRegion(Integer region) {
        this.region = region;
    }

    @JsonProperty
    public String getAreaCode() {
        return areaCode;
    }

    public void setAreaCode(String areaCode) {
        this.areaCode = areaCode == null ? null : areaCode.trim();
    }

    /**
     * 设置子节点数量
     */
    @JsonProperty
    public int getChildCount() {
        return childCount;
    }

    public void setChildCount(int childCount) {
        this.childCount = childCount;
    }

    /**
     * 设置父级节点名称
     */
    @JsonProperty
    public String getParentName() {
        return parentName;
    }

    public void setParentName(String parentName) {
        this.parentName = parentName;
    }

    /**
     * 设置 是否为父级节点
     */
    @JsonProperty
    public Boolean getIsParent() {
        return isParent == null ? childCount > 0 : isParent;
    }

    public void setIsParent(Boolean isParent) {
        this.isParent = isParent;
    }

    public String getCarPrefix() {
        return carPrefix;
    }

    public void setCarPrefix(String carPrefix) {
        this.carPrefix = carPrefix;
    }

    /**
     * 获取子区域
     *
     * @return
     */
    @JsonProperty
    public List<Area> getAreas() {
        return areas;
    }

    /**
     * 设置子区域
     *
     * @param areas
     */
    public void setAreas(List<Area> areas) {
        this.areas = areas;
    }

    /**
     * 获取地区首字母
     *
     * @return
     */
    public String getAreaFirstLetter() {
        return areaFirstLetter;
    }

    /**
     * 设置地区首字母
     *
     * @param areaFirstLetter
     */
    public void setAreaFirstLetter(String areaFirstLetter) {
        this.areaFirstLetter = areaFirstLetter;
    }
}